package com.example.win.android_banduyujia.peopleactivity.activity.activity.dooractivity;

import android.os.Bundle;
import android.text.Editable;
import android.text.TextWatcher;
import android.view.View;
import android.widget.EditText;
import android.widget.ImageView;

import com.example.win.android_banduyujia.R;
import com.example.win.android_banduyujia.lib.util.StrUtils;
import com.example.win.android_banduyujia.peopleactivity.ui.activity.BaseTitleBarActivity;

/**
 * Created by Win on 2015/9/10.
 */
public class classesActivity extends BaseTitleBarActivity {

    private EditText  mEditclass;
    private ImageView mImageCancel;
    private String    mNickClasses = " ";

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.layout_classes_page);

        InitTitles();
        InitViews();
    }

    private void InitTitles() {
        showLeftBackButton();
        setTitle(R.string.text_view_teaching_number);
        setRightTextViewListener(R.string.layout_data_save_button, mRightListener);
    }

    private View.OnClickListener mRightListener = new View.OnClickListener(){

        @Override
        public void onClick(View v) {
            if(StrUtils.isEmpty(mNickClasses)){
                  showToast(R.string.layout_data_save_button);
                return;
            }
            save();
        }
    };

    private void save() {

    }

    private void InitViews() {
        mImageCancel= (ImageView) findViewById(R.id.update_number_image_icon);
        mEditclass= (EditText) findViewById(R.id.update_number_edit_text);
        mEditclass.addTextChangedListener(new TextWatcher() {
            @Override
            public void beforeTextChanged(CharSequence s, int start, int count, int after) {

            }

            @Override
            public void onTextChanged(CharSequence s, int start, int before, int count) {

            }

            @Override
            public void afterTextChanged(Editable s) {
                mNickClasses = s.toString();
                if (StrUtils.isEmpty(mNickClasses)) {
                    mImageCancel.setVisibility(View.GONE);
                } else {
                    mImageCancel.setVisibility(View.VISIBLE);
                }
            }
        });
        mImageCancel.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                mEditclass.setText("  ");
            }
        });
    }
    }
